package club.xyes.remotedisplay.util;

public class ArrayUtil {
    public static int[] toIntArray(short[] arr) {
        int[] res = new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            res[i] = arr[i];
        }
        return res;
    }

    public static int[][] toIntArray(short[][] arr) {
        int[][] res = new int[arr.length][];
        for (int i = 0; i < arr.length; i++) {
            res[i] = toIntArray(arr[i]);
        }
        return res;
    }

    public static int[] flat(int[][] arrays) {
        int h = arrays.length;
        int w = arrays[0].length;
        int[] dataArray = new int[h * w];
        int index = 0;
        for (int[] arr : arrays) {
            for (int d : arr) {
                dataArray[index++] = d;
            }
        }
        return dataArray;
    }
}
